package com.baiyi.service.serialservice.serialdataservice.data.entity;

import android.os.Parcel;
import android.os.Parcelable;

public class SerialData implements Parcelable{

    public static final String STATE_GET = "GET";
    public static final String STATE_STATE = "STATE";
    public static final String STATE_POST = "POST";
    public static final String STATE_DELETE = "DELETE";

    public static final String CMD_ALLSTATE = "allState";
    public static final String CMD_GPU = "gpu";
    public static final String CMD_CPU = "cpu";
    public static final String CMD_MEM = "mem";
    public static final String CMD_NET = "net";
    public static final String CMD_DISK = "disk";
    public static final String CMD_FAN = "fan";
    public static final String CMD_OTHER = "other";
    /**
     * - GET：获取信息
     * - STATE：状态通知（心跳、状态变化）
     * - POST：发送要处理的数据（发指令）
     * - DELETE：请求删除数据
     */
    private String requestState;
    /**
     * allState
     * gpu
     * cpu
     * mem
     * net
     * disk
     * fan
     * other
     */
    private String cmdType;
    private String version;
    private DataHeader dataHeader;
    private String dataContent;

    protected SerialData(Parcel in) {
        requestState = in.readString();
        cmdType = in.readString();
        version = in.readString();
        dataHeader = in.readParcelable(DataHeader.class.getClassLoader());
        dataContent = in.readString();
    }

    public SerialData() {
    }

    public static final Creator<SerialData> CREATOR = new Creator<SerialData>() {
        @Override
        public SerialData createFromParcel(Parcel in) {
            return new SerialData(in);
        }

        @Override
        public SerialData[] newArray(int size) {
            return new SerialData[size];
        }
    };

    public String getRequestState() {
        return requestState;
    }

    public void setRequestState(String requestState) {
        this.requestState = requestState;
    }

    public String getCmdType() {
        return cmdType;
    }

    public void setCmdType(String cmdType) {
        this.cmdType = cmdType;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public DataHeader getDataHeader() {
        return dataHeader;
    }

    public void setDataHeader(DataHeader dataHeader) {
        this.dataHeader = dataHeader;
    }

    public String getDataContent() {
        return dataContent;
    }

    public void setDataContent(String dataContent) {
        this.dataContent = dataContent;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(requestState);
        dest.writeString(cmdType);
        dest.writeString(version);
        dest.writeParcelable(dataHeader, flags);
        dest.writeString(dataContent);
    }

    @Override
    public String toString() {
        return "SerialData{" +
                "requestState='" + requestState + '\'' +
                ", cmdType='" + cmdType + '\'' +
                ", version='" + version + '\'' +
                ", dataHeader=" + dataHeader +
                ", dataContent='" + dataContent + '\'' +
                '}';
    }
}
